package com.blt.car.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

import com.blt.car.R;
import com.blt.car.utils.Uiutils;


/**
 * 通用dialog
 * xugaopan
 * on 2017/guide_1/12.
 */
public class CommonDialog extends Dialog implements View.OnClickListener {
    private Context context;

    private TextView mTitle;
    private TextView mContent;
    private TextView mCancel;
    private TextView mConfirm;
    private View line;

    private OnPositiveButton positiveListener;
    private OnCancelListener onCancelListener;

    public void setPositiveListener(OnPositiveButton positiveListener) {
        this.positiveListener = positiveListener;
    }

    public interface OnPositiveButton {
        void onPositiveButton(View v);
    }

    @Override
    public void setOnCancelListener(OnCancelListener listener) {
        onCancelListener = listener;
    }

    public CommonDialog(Context context) {
        super(context, R.style.CommonDialog);
        this.context = context;
        setCancelable(false);
        setCanceledOnTouchOutside(true);
//        setCanceledOnTouchOutside(false);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_common_center);

    }


    public void setTitle(String title) {
        if (title != null) {
            mTitle.setText(title);
        }
    }

    public void setContent(String content) {
        if (content != null) {
            mContent.setText(content);
        }
    }


    @Override
    protected void onStart() {
        super.onStart();
        if (getWindow() != null) {
            WindowManager.LayoutParams params = getWindow()
                    .getAttributes();
            params.width = Uiutils.dip2px(260);
            params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
            getWindow().setAttributes(params);
        }
    }


    @Override
    public void onClick(View v) {


    }
}
